package java6;

import java.util.Scanner;

public class Code079 {
	public static void main(String[] args) {
		System.out.println("\t计算器");
		String a = "y";
		while(a.equals("y")){
			System.out.println("请输入第一个数: ");
			Scanner input = new Scanner(System.in);
			if(input.hasNextDouble()){
				double num1 = input.nextDouble();
				System.out.println("请输入第二个数: ");
				if(input.hasNextDouble()){
					double num2 = input.nextDouble();
					System.out.println("请输入运算符:1.+ 2.- 3.* 4./");
					String num3 =input.next();
					switch(num3){
					case "1":
						System.out.println(num1+num2);
						System.out.println("是否继续(y/n)");
						String a1 =input.next();
						a=a1;
						break;
					case "2":
						System.out.println(num1-num2);
						System.out.println("是否继续(y/n)");
						String a2 =input.next();
						a=a2;
						break;
					case "3":
						System.out.println(num1*num2);
						System.out.println("是否继续(y/n)");
						String a3 =input.next();
						a=a3;
						break;
					case "4":
						if(num2!=0){
							System.out.println(num1+num2);
							System.out.println("是否继续(y/n)");
							String a4 =input.next();
							a=a4;
							break;
						}
						else{
							System.out.println("除数不能为零！");

							break;
						}
					default:
						System.out.println("运算符输入错误！");
						break;
					}
				}else{
					System.out.println("数字输入错误！ ");
				}
			}else{
				System.out.println("数字输入错误！ ");
			}
		}
		System.out.println("谢谢使用 ");
	}
}
